package com.qr.service.wmyh.impl;

import java.util.List;
import java.util.Map;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.mapping.ResultMapping;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import cn.krui.helper.db.DBHelper;
import cn.krui.helper.db.DataPage;
import com.qr.bean.wmyh.JbrUserCommissionList;
import com.qr.bean.wmyh.JbrUserCommissionListView;
import com.qr.controller.WmyhBase;
import com.qr.mapper.wmyh.JbrUserCommissionListMapper;
import com.qr.mapper.wmyh.JbrUserCommissionListMapperView;
import com.qr.service.wmyh.JbrUserCommissionListService;
//import org.apache.dubbo.config.annotation.Service;

/**
 * @author: zc
 * email: zc8023zs@163.com
 * create_time: 2020/8/11 13:02:53
 */
@Service
//@Service(version = "1.0.0",group="dubbo")
public class JbrUserCommissionListServiceImpl implements JbrUserCommissionListService{
    @Autowired
    private JbrUserCommissionListMapper jbrUserCommissionListMapper;

    @Autowired
    private JbrUserCommissionListMapperView jbrUserCommissionListMapperView;
    
    @Autowired
    private DBHelper dbHelper;

    /**
     * 构造查询条件
     */
    private QueryWrapper<JbrUserCommissionList> InitWrapper(JbrUserCommissionList where){
        QueryWrapper<JbrUserCommissionList> whereWrapper = new QueryWrapper<JbrUserCommissionList>();
        if(where.getId()!=null){
			whereWrapper.eq("id",where.getId());
		}
        if(where.getUser_id()!=null){
			whereWrapper.eq("user_id",where.getUser_id());
		}
        if(where.getSub_order_id()!=null){
			whereWrapper.eq("sub_order_id",where.getSub_order_id());
		}
        if(where.getSub_order_num()!=null){
			whereWrapper.eq("sub_order_num",where.getSub_order_num());
		}
        if(where.getLevel()!=null){
			whereWrapper.eq("level",where.getLevel());
		}
        if(where.getApply_id()!=null){
			whereWrapper.eq("apply_id",where.getApply_id());
		}
        if(where.getService_id()!=null){
			whereWrapper.eq("service_id",where.getService_id());
		}
        if(where.getTrade_commission()!=null){
			whereWrapper.eq("trade_commission",where.getTrade_commission());
		}
        if(where.getType()!=null){
			whereWrapper.eq("type",where.getType());
		}
        if(where.getStatus()!=null){
			whereWrapper.eq("status",where.getStatus());
		}
        if(where.getAdd_time()!=null){
			whereWrapper.eq("add_time",where.getAdd_time());
		}
        if(where.getSettlement_time()!=null){
			whereWrapper.eq("settlement_time",where.getSettlement_time());
		}
        if(where.getRemark()!=null){
			whereWrapper.eq("remark",where.getRemark());
		}
        if(where.getCommission_id()!=null){
			whereWrapper.eq("commission_id",where.getCommission_id());
		}
        return whereWrapper;
    }

    private QueryWrapper<JbrUserCommissionListView> InitWrapperView(JbrUserCommissionListView where){
        QueryWrapper<JbrUserCommissionListView> whereWrapper = new QueryWrapper<JbrUserCommissionListView>();
        if(where.getId()!=null){
			whereWrapper.eq("id",where.getId());
		}
        if(where.getUser_id()!=null){
			whereWrapper.eq("user_id",where.getUser_id());
		}
        if(where.getSub_order_id()!=null){
			whereWrapper.eq("sub_order_id",where.getSub_order_id());
		}
        if(where.getSub_order_num()!=null){
			whereWrapper.eq("sub_order_num",where.getSub_order_num());
		}
        if(where.getLevel()!=null){
			whereWrapper.eq("level",where.getLevel());
		}
        if(where.getApply_id()!=null){
			whereWrapper.eq("apply_id",where.getApply_id());
		}
        if(where.getService_id()!=null){
			whereWrapper.eq("service_id",where.getService_id());
		}
        if(where.getTrade_commission()!=null){
			whereWrapper.eq("trade_commission",where.getTrade_commission());
		}
        if(where.getType()!=null){
			whereWrapper.eq("type",where.getType());
		}
        if(where.getStatus()!=null){
			whereWrapper.eq("status",where.getStatus());
		}
        if(where.getAdd_time()!=null){
			whereWrapper.eq("add_time",where.getAdd_time());
		}
        if(where.getSettlement_time()!=null){
			whereWrapper.eq("settlement_time",where.getSettlement_time());
		}
        if(where.getRemark()!=null){
			whereWrapper.eq("remark",where.getRemark());
		}
        if(where.getCommission_id()!=null){
			whereWrapper.eq("commission_id",where.getCommission_id());
		}
        return whereWrapper;
    }

    /**
     * 用户佣金明细表新增
     * @param model 用户佣金明细表实体
     * @return 影响行数
     */
	@Override
    public Integer add(JbrUserCommissionList model){
        return jbrUserCommissionListMapper.insert(model);
    }

    /**
     * 用户佣金明细表修改byid
     * @param model 用户佣金明细表实体
     * @return 影响行数
     */
	@Override
    public Integer update(JbrUserCommissionList model) {
        return jbrUserCommissionListMapper.updateById(model);
    }

    /**
     * 用户佣金明细表修改by条件
     * @param model 用户佣金明细表实体
     * @param where 用户佣金明细表条件
     * @return 影响行数
     */
	@Override
    public Integer update(JbrUserCommissionList model, Wrapper<JbrUserCommissionList> where) {
        return jbrUserCommissionListMapper.update(model, where);
    }

    /**
     * 用户佣金明细表修改by条件-自动封装Wrapper
     * @param model 用户佣金明细表实体
     * @return 影响行数
     */
	@Override
    public Integer update(JbrUserCommissionList model, JbrUserCommissionList where) {
        Wrapper<JbrUserCommissionList> wrapper = InitWrapper(where);
        return update(model, wrapper);
    }

    /**
     * 用户佣金明细表修改bySQL *version_id = newVersion where version_id = oldVersion
     * @param fields 修改的数据 col1=xx,col2=yy
     * @param where 参数化条件 col1=#{col1}
     * @param params 条件参数 col1=xx
     * @return 影响行数
     */
	@Override
    public Integer update(Map<String, Object> fields, String where, Map<String, Object> params) {
        return dbHelper.update("jbr_user_commission_list", fields, where, params);
    }

    /**
     * 用户佣金明细表删除byid
     * @param id 用户佣金明细表主键
     * @return 影响行数
     */
	@Override
    public Integer del(int id) {
        return jbrUserCommissionListMapper.deleteById(id);
    }

    /**
     * 用户佣金明细表删除by条件
     * @param where 用户佣金明细表条件
     * @return 影响行数
     */
	@Override
    public Integer del(Wrapper<JbrUserCommissionList> where) {
        return jbrUserCommissionListMapper.delete(where);
    }

    /**
     * 用户佣金明细表删除by条件-自动封装Wrapper
     * @param where 用户佣金明细表条件
     * @return 影响行数
     */
    @Override
    public Integer del(JbrUserCommissionList where) { 
        Wrapper<JbrUserCommissionList> wrapper = InitWrapper(where);
        return del(wrapper);
    }

    /**
     * 用户佣金明细表批量删除byid
     * @param ids 用户佣金明细表主键集合
     * @return 影响行数
     */
	@Override
    public Integer del(List<Integer> ids){
        return jbrUserCommissionListMapper.deleteBatchIds(ids);
    }

    /**
     * 用户佣金明细表批量删除bymap条件
     * @param map 用户佣金明细表map条件
     * @return 影响行数
     */
	@Override
    public Integer del(Map<String,Object> map){
        return jbrUserCommissionListMapper.deleteByMap(map);
    }

    /**
     * 用户佣金明细表详情byid
     * @param id 用户佣金明细表主键
     * @return 用户佣金明细表详情
     */
	@Override
    public JbrUserCommissionListView info(int id){
        return jbrUserCommissionListMapperView.selectById(id);
    }

    /**
     * 用户佣金明细表详情by条件
     * @param where 用户佣金明细表条件
     * @return 用户佣金明细表详情
     */
	@Override
    public JbrUserCommissionListView info(Wrapper<JbrUserCommissionListView> where){
        return jbrUserCommissionListMapperView.selectOne(where);
    }

    /**
     * 用户佣金明细表详情by条件-自动封装Wrapper
     * @param where 用户佣金明细表条件
     * @return 用户佣金明细表详情
     */
	@Override
    public JbrUserCommissionListView info(JbrUserCommissionListView where) {
        Wrapper<JbrUserCommissionListView> wrapper = InitWrapperView(where);
        return info(wrapper);
    }

    /**
     * 用户佣金明细表详情bySQL
     * @param columns  列名col1,col2,col3^
     * @param where 条件 col1=#{col1}
     * @param params col1:xx
     * @param mappings col1->col1
     * @return
     */
	@Override
    public JbrUserCommissionList info(String columns, String where, Map<String, Object> params, ResultMapping mappings) {
        return dbHelper.selectOne(columns, "jbr_user_commission_list", where, params, JbrUserCommissionList.class, mappings);
    }

    /**
     * 用户佣金明细表批量查询byid
     * @param ids 用户佣金明细表主键集合
     * @return 用户佣金明细表列表
     */
	@Override
    public List<JbrUserCommissionListView> select(List<Integer> ids){
        return jbrUserCommissionListMapperView.selectBatchIds(ids);
    }

    /**
     * 用户佣金明细表批量查询by条件
     * @param where 用户佣金明细表条件
     * @return 用户佣金明细表列表
     */
	@Override
    public List<JbrUserCommissionListView> select(Wrapper<JbrUserCommissionListView> where){
        return jbrUserCommissionListMapperView.selectList(where);
    }

    /**
     * 用户佣金明细表批量查询by条件-自动封装Wrapper
     * @param where 用户佣金明细表条件
     * @return 用户佣金明细表列表
     */
    @Override
    public List<JbrUserCommissionListView> select(JbrUserCommissionListView where) {
        Wrapper<JbrUserCommissionListView> wrapper = InitWrapperView(where);		
        return select(wrapper);
    }

    /**
     * 用户佣金明细表批量查询bymap条件
     * @param map 用户佣金明细表map条件
     * @return 用户佣金明细表列表
     */
	@Override
    public List<JbrUserCommissionListView> select(Map<String,Object> map){
        return jbrUserCommissionListMapperView.selectByMap(map);
    }

    /**
     * 用户佣金明细表批量查询b条件分页
     * @param page 分页条件
     * @param where 查询条件
     * @return
     */
	@Override
    public IPage<JbrUserCommissionListView> select(IPage<JbrUserCommissionListView> page, Wrapper<JbrUserCommissionListView> where){
        return jbrUserCommissionListMapperView.selectPage(page, where);
    }

    /**
     * 用户佣金明细表批量查询b条件分页
     * @param page 分页条件
     * @param where 查询条件
     * @return
     */
    @Override
    public IPage<JbrUserCommissionListView> select(IPage<JbrUserCommissionListView> page, JbrUserCommissionListView where) {
		Wrapper<JbrUserCommissionListView> wrapper = InitWrapperView(where);		
        return select(page, wrapper);
    }

    /**
     * 用户佣金明细表查询记录数
     * @param where 查询条件
     * @return
     */
	@Override
    public Integer selectCount(Wrapper<JbrUserCommissionListView> where){
        return jbrUserCommissionListMapperView.selectCount(where);
    }

    /**
     * 用户佣金明细表查询记录数
     * @param where 查询条件
     * @return
     */
	@Override
    public Integer selectCount(JbrUserCommissionListView where){
		Wrapper<JbrUserCommissionListView> wrapper = InitWrapperView(where);
        return selectCount(wrapper);
    }

    /**
     * 用户佣金明细表批量查询bySQL条件分页
     * @param columns 列col1,col2,col3……
     * @param where 条件col1=#{col1} and col2=#{col2}
     * @param orderBy 排序字段
     * @param params 参数化 col1=xx
     * @param pageNumber 分页页码
     * @param pageSize 每页行数
     * @param mappings 查询列和实体映射
     * @return 分页之后的数据含总行数
     */
	@Override
    public DataPage<JbrUserCommissionListView> select(String columns, String where, String orderBy, Map<String, Object> params, int pageNumber, int pageSize, ResultMapping mappings){
        return dbHelper.select(columns, "jbr_user_commission_list", where, orderBy, params, pageNumber, pageSize, JbrUserCommissionListView.class,mappings);
    }

    /**
     * 用户佣金明细表批量查询bySQL条件
     * @param columns 列col1,col2,col3……
     * @param where 条件col1=#{col1} and col2=#{col2}
     * @param params 参数化 col1=xx
     * @param mappings 查询列和实体映射
     * @return 栏目扩展列表
     */
	@Override
    public List<JbrUserCommissionListView> select(String columns, String where, Map<String, Object> params, ResultMapping mappings){
        return dbHelper.select(columns,"jbr_user_commission_list",where,params,JbrUserCommissionListView.class,mappings);
    }
}